Android Firebase Configration
Setting up Firebase for your HandyHue App Project with Android.
Add Android App With The Package Name In Firebase Console:
- On the Firebase console, click the Android icon.
- Enter Package Name (e.g., com.example.userApp) and click on register app.
- After registering the app, you will receive the Google JSON file, download it and save it to the
android/app/
folder. Otherwise you can download later after add SHA fingerprint in firebase project so google login will work with your project. Check below how to add SHA in fribase
Set Up Firebase Authentication
- Go to
Build -> Authentication
tab and click on Get started.
- Then select the Email/Password, Google, Apple, and Phone Number one by one and enable them.
- Re-check if all these 3 modes of authentication are enabled or not.
SHA Fingerprint
SHA-1 fingerprint is a unique key generated for your PC that can be used for signing. It is important to have in the add Firebase as we are using Google Login and OTP Login, and to authorize these logins, we need a SHA Fingerprint certificate.
Add a SHA fingerprint to Firebase:
-
Follow these steps if you didn't initially provide a SHA certificate fingerprint for your Firebase Android app or if you need to add an additional one:
- In your Project settings, go to the Your apps card. and Select the Firebase Android app to which you want to add a SHA fingerprint.
- Click Add fingerprint.
- Enter or paste the SHA fingerprint, then click Save.
How to generate the SHA from Android Studio
There are two types of SHA Fingerprint, Release SHA Fingerprint, and Debug SHA Fingerprint. Here we will see how to generate both types of SHA Fingerprint.
-
Create a file in android folder of your project name
key.properties
if not exists. -
Add properties and it's value below
storePassword=<Your JKS password>
keyPassword=<Your JKS Key Password>
keyAlias=<You JKS Key Alias>
storeFile=<Your jks file location path> -
Add following line to your
Android/app/build.gradle
file above the allandroid
block (Check if this line already exist or not)def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists())
{
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
} -
Now in app:build.gradle android block check for below lines if not exist Add into your Android/app/build.gradle
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
} -
Open your terminal and enter following command
cd android
./gradlew signinReport
Wait for a while it will generate your SHA Copy Both SHA1 and SHA256 for variant & config Debug
and Release
and add to Firebase
- Open your Play Console
- Go to Setup → App signing
- Copy SHA1 and SHA256 of both "App signing key certificate" and "Upload key certificate"
- Paste it to Firebase
Great! You have successfully configured the Android App Firebase for Push Notificationa and Google Social Login!